<?php

namespace maotool\src\test;

use maotool\core\Container;
use maotool\orm\mapper\MapperLoader;
use maotool\orm\mapper\MapperScan;
use maotool\orm\mapper\MapperUtil;
use maotool\orm\mapper\PageHelper;
use maotool\orm\mapper\PageInfo;
use maotool\orm\mapper\PageParam;
use PHPUnit\Framework\TestCase;

class Demo1Test extends TestCase
{

    /**
     * @Autowired maotool\src\test\UsersDao
     */
    private $usersDao;

    public function testDemo1()
    {
        MapperUtil::scan("maotool:/src/test/resources/**/*.xml");
        $param = new PageParam();
        $param->setPageNo(1);
        $param->setPageSize(10);
        PageHelper::startPage($param->getPageNo(), $param->getPageSize());
        $list = Container::getClass("maotool\src\\test\UsersDao")->getList("beian");
        $page = new PageInfo($list);
        var_dump($page);
        $this->assertTrue(true);
    }

    public function testDemo2()
    {
        print_r(MapperLoader::parse("getList", "maotool:/src/test/resources/UsersDao.xml", ["zhang", 10]));die;
        $this->assertTrue(true);
    }

    public function testDemo3()
    {
        echo rand(0, 1);
        $this->assertTrue(true);
    }

    public function testDemo4()
    {
        $param = new PageParam();
        $param->setPageNo(1);
        $param->setPageSize(10);
        PageHelper::startPage($param->getPageNo(), $param->getPageSize());
        $list = MapperLoader::object("maotool:/src/test/resources/UsersDao.xml")
            ->getList("beian");
        $page = new PageInfo($list);
        var_dump($page);
        $this->assertTrue(true);
    }

}